package com.itheima.listener;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.model.article.pojos.ApArticleConfig;
import com.itheima.service.AriticleConfigService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author yunfei
 * @date 2022年10月22日 19:06
 */
@Component
public class WMNewsListener {
    @Autowired
    private AriticleConfigService configService;

    @RabbitListener(queues = "news_down_up")
    public void handlerMsg(Map map) {
        // 根据id修改一个文章的上下架状态
        configService.update(Wrappers.<ApArticleConfig>lambdaUpdate()
                .eq(ApArticleConfig::getArticleId, map.get("articleId"))
                .set(ApArticleConfig::getIsDown, map.get("enable")));
    }
}
